/***************************************************************************
 *   Copyright (C) 2007 by Phillip Aldridge   *
 *   phillip@imi21.com   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#include "wundergrunddlg.h"


#include <qpushbutton.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qcheckbox.h>
#include <qspinbox.h>
#include <qlineedit.h>

WundergrundDlg::WundergrundDlg(QWidget* parent):
         QDialog( parent)
{
setCaption ( "Wundergrund Configuration");
QBoxLayout* topLayout = new QVBoxLayout( this,5,5 );
   QGridLayout * g1 = new QGridLayout( topLayout,4,2,5  );

   QBoxLayout * b5 = new QHBoxLayout(topLayout );
   QBoxLayout * bButtons = new QHBoxLayout( topLayout);

   QLabel *label1 = new QLabel( "Wundergrund site : ", this );
   g1->addWidget( label1,0,0);
   QLineEdit *le1= new QLineEdit(this);
   g1->addWidget( le1,0,1);

   QLabel *label2 = new QLabel( "Wundergrund Path : ", this );
   g1->addWidget( label2,1,0);
   QLineEdit *le2= new QLineEdit(this);
   g1->addWidget( le2,1,1);

   QLabel *label3 = new QLabel( "ID : ", this );
   g1->addWidget( label3,2,0);
   leID= new QLineEdit(this);
   g1->addWidget( leID,2,1);

   QLabel *label4 = new QLabel( "Password : ", this );
   g1->addWidget( label4,3,0);
   lePassword= new QLineEdit(this);
   g1->addWidget( lePassword,3,1);

   QLabel *label5 = new QLabel( "Update rate (minutes) : ", this );
   g1->addWidget( label5,4,0);
   sbUpdateInterval= new QSpinBox(1,60,1,this);
   g1->addWidget(sbUpdateInterval,4,1);


QLabel *label6 = new QLabel(this);
label6-> setText("This allows you to publish you station data to http://www.wunderground.com.\nYou beed to have an active account with an ID and Password.\nLeave the update rate set to 0 if you do not use this function.");
label6-> setFrameStyle( QFrame::Panel | QFrame::Sunken );
   g1-> addMultiCellWidget( label6,5,5,0,1);

   butReset = new QPushButton("&Reset", this);
   butCancel = new QPushButton("&Cancel", this);
   butOK = new QPushButton("&OK", this );
   bButtons->addWidget( butReset );
   bButtons->addWidget( butCancel );
   bButtons->addWidget( butOK );

   topLayout->activate();
   connect( butReset, SIGNAL( clicked() ), this, SLOT( reset() ) ); 
   connect( butCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
   connect( butOK, SIGNAL( clicked() ), this, SLOT( accept() ) );
}


WundergrundDlg::~WundergrundDlg()
{
}
void WundergrundDlg::setLogin(QString l,QString p)
{
   leID->setText(l);
   lePassword->setText(p);
}
QString WundergrundDlg::id()
{
   return leID->text();
}
QString WundergrundDlg::password()
{
   return lePassword->text();
}
void WundergrundDlg::setUpdateInterval(int i)
{
   sbUpdateInterval->setValue(i);
}
int WundergrundDlg::updateInterval()
{
   return sbUpdateInterval->value();
}
void WundergrundDlg::reset()
{
   qDebug( "Reset");
}

void WundergrundDlg::accept()
{
   qDebug( "Accept");
   QDialog::accept();
}
void WundergrundDlg::reject()
{
   qDebug( "Reject");
   QDialog::reject();
}
